﻿<%@ Import Namespace="System.Collections.Generic"%>
<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        //DateTime data = DateTime.Now;
        //int day = data.Day;
        //int month = data.Month;
        //int year = data.Year;
        ////new ProductDayService()
        Application.Add("userCount", 0);
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown
        Application.Remove("userCount");
    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs
    }

    void Session_Start(object sender, EventArgs e) 
    {
        Application["userCount"] = Convert.ToInt32(Application["userCount"].ToString()) + 1;
        Session.Add("database", new LinQProject.FarmacieDataClassesDataContext());
        Session.Add("username", string.Empty);
        Session.Add("userId",new Guid());
        Session.Add("index",0);
        Session.Add("SelectionForCos", null);
        Session.Add("SelectionForRequest", null);
        Session.Add("Selection", null); 
    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.
        Application["userCount"] = Convert.ToInt32(Application["userCount"].ToString()) - 1;
        Session.RemoveAll();
    }
       
</script>
